package com.lmiot.xyclick.Activity;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SwitchCompat;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.Gson;
import com.lmiot.xyclick.AD.SDK.ADSDK;
import com.lmiot.xyclick.ActionDetailBean.DetailBean;
import com.lmiot.xyclick.App.MyApp;
import com.lmiot.xyclick.Auto.AutoTypeEnum;
import com.lmiot.xyclick.Auto.AutoUtils;
import com.lmiot.xyclick.Bean.InitFloatBean;
import com.lmiot.xyclick.Bean.ResumeActivityBean;
import com.lmiot.xyclick.Bean.SQL.ActionBean;
import com.lmiot.xyclick.Bean.SQL.ActionBeanSqlUtil;
import com.lmiot.xyclick.Bean.SQL.AutoBean;
import com.lmiot.xyclick.Bean.SQL.AutoBeanSqlUtil;
import com.lmiot.xyclick.Bean.SQL.GroupBean;
import com.lmiot.xyclick.Bean.SQL.GroupBeanSqlUtil;
import com.lmiot.xyclick.Bean.TimerBean;
import com.lmiot.xyclick.Notic.NoticManager;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.AlarmUtil;
import com.lmiot.xyclick.Util.ClickUtils;
import com.lmiot.xyclick.Util.Constants;
import com.lmiot.xyclick.Util.DataUtil;
import com.lmiot.xyclick.Util.DpUtil;
import com.lmiot.xyclick.Util.EditDialogUtil;
import com.lmiot.xyclick.Util.FloatManager;
import com.lmiot.xyclick.Util.ImgUtil;
import com.lmiot.xyclick.Util.LayoutDialogUtil;
import com.lmiot.xyclick.Util.LogUtil;
import com.lmiot.xyclick.Util.MathUtils;
import com.lmiot.xyclick.Util.RandomUtil;
import com.lmiot.xyclick.Util.StateBarUtil;
import com.lmiot.xyclick.Util.TimeUtils;
import com.xiaoyi.intentsdklibrary.CheckUtil;
import com.xiaoyi.intentsdklibrary.SDK.Action.ActionNormalSDK;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView;
import com.yanzhenjie.recyclerview.swipe.touch.OnItemMoveListener;
import com.yanzhenjie.recyclerview.swipe.touch.OnItemStateChangedListener;
import com.yanzhenjie.recyclerview.swipe.widget.DefaultItemDecoration;
import com.yhao.floatwindow.FloatUtil;
import com.yhao.floatwindow.FloatWindow;
import com.youyi.yychosesdk.SDK.YYChoseSDK;
import com.youyi.yychosesdk.models.album.entity.Photo;
import com.youyi.yycutsdklibrary.SDK.YYCutSDK;
import com.youyi.yypermissionlibrary.SDK.OnPerListener;
import com.youyi.yypermissionlibrary.SDK.YYPerUtils;
import com.youyi.yyviewsdklibrary.ArrayGson;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import com.youyi.yyviewsdklibrary.View.MyTitleView;
import com.youyi.yyviewsdklibrary.View.TitleBarView;
import com.youyi.yyviewsdklibrary.View.roundedimageview.RoundedImageView;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class AddActionActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "AddActionActivity00";
    private long exitTime = 0;
    private ActionAdapter mActionAdapter;
    RoundedImageView mAutoIcon;
    private Dialog mDialog;
    private Dialog mDialogChose;
    TextView mIdAutoTypeText;
    RadioButton mIdBt01;
    RadioButton mIdBt02;
    RadioButton mIdBt03;
    ImageView mIdDelIcon;
    ImageView mIdEditGroup;
    EditText mIdEditName;
    EditText mIdEditTime;
    TextView mIdGroup;
    LinearLayout mIdGroupLayout;
    CheckBox mIdRandomCheck;
    LinearLayout mIdRandomLayout;
    EditText mIdRandomMax;
    EditText mIdRandomMin;
    ImageView mIdShouqi;
    LinearLayout mIdShouqiLayout;
    SwitchCompat mIdSwitch;
    LinearLayout mIdSwitchLayout;
    MyTitleView mIdSwitchText;
    TitleBarView mIdTitleBar;
    LinearLayout mIdTopLayout;
    private Intent mIntent;
    SwipeMenuRecyclerView mRecyclerView;

    @Override // android.support.v4.app.SupportActivity, com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_add_action);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        initView();
        StateBarUtil.immersive(this, getResources().getColor(R.color.colorAccent));
        StateBarUtil.setPadding(this, this.mIdTitleBar);
        init();
        setRecycleView();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(ResumeActivityBean resumeActivityBean) {
        freshActionData();
    }

    private void init() {
        AutoTypeEnum autoTypeEnum;
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                AddActionActivity.this.exit();
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
                AddActionActivity.this.saveData();
            }
        });
        GroupBean searchByID = GroupBeanSqlUtil.getInstance().searchByID(AutoUtils.mGroupID);
        if (searchByID != null) {
            this.mIdGroup.setText(searchByID.getGroupName());
        } else {
            this.mIdGroup.setText("默认分组");
        }
        this.mIdTitleBar.setTitle(AutoUtils.mAutoName);
        this.mIdAutoTypeText.setText(AutoUtils.mAutoTypeDetail);
        this.mIdEditName.setText(AutoUtils.mAutoName);
        EditText editText = this.mIdEditTime;
        editText.setText(AutoUtils.mRepeatTime + "");
        try {
            autoTypeEnum = AutoTypeEnum.valueOf(AutoUtils.mAutoType);
        } catch (Exception unused) {
            autoTypeEnum = AutoTypeEnum.click;
        }

        switch (autoTypeEnum) {
            case click:
                this.mIdBt01.setChecked(true);
                this.mIdSwitchText.setTitle("通知栏显示");
                this.mIdSwitch.setChecked(AutoUtils.mShowNotic);
                TextView textView = this.mIdAutoTypeText;
                textView.setText(AutoUtils.mAutoTypeDetail + "");
                break;
            case time:
                this.mIdBt02.setChecked(true);
                this.mIdSwitchText.setTitle("开启该定时任务");
                this.mIdSwitch.setChecked(AutoUtils.mIsEnable);
                List<TimerBean> normalTimeToTimeList = AlarmUtil.normalTimeToTimeList(AutoUtils.mAutoTypeDetail);
                TextView textView2 = this.mIdAutoTypeText;
                textView2.setText(normalTimeToTimeList.size() + "组定时");
                break;
            case notic:
            case notic_now:
            case screen:
            case screen_now:
                this.mIdBt03.setChecked(true);
                this.mIdSwitchText.setTitle("开启该触发任务");
                this.mIdSwitch.setChecked(AutoUtils.mIsEnable);
                TextView textView3 = this.mIdAutoTypeText;
                textView3.setText(getString(R.string.active_text) + AutoUtils.mAutoTypeDetail);
                break;
        }
        if (AutoUtils.mIsRandomRepeat) {
            this.mIdRandomLayout.setVisibility(View.VISIBLE);
            this.mIdRandomCheck.setChecked(true);
            this.mIdEditTime.setVisibility(View.GONE);
            EditText editText2 = this.mIdRandomMin;
            editText2.setText(AutoUtils.mRandomMin + "");
            EditText editText3 = this.mIdRandomMax;
            editText3.setText(AutoUtils.mRandomMax + "");
            return;
        }
        this.mIdRandomCheck.setChecked(false);
        this.mIdRandomLayout.setVisibility(View.GONE);
        this.mIdEditTime.setVisibility(View.VISIBLE);
    }

    public void onRestart() {
        super.onRestart();
    }

    @Override
    public void onResume() {
        super.onResume();
        showListview();
        showAutoIcon();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showAutoIcon() {
        boolean hasSD = YYPerUtils.hasSD();
        Integer valueOf = Integer.valueOf((int) R.drawable.play_auto_blue);
        if (hasSD) {
            File file = new File(Environment.getExternalStorageDirectory() + "/XYClick/temp", AutoUtils.mAutoID + ".jpg");
            if (file.exists()) {
                Glide.with(MyApp.getContext()).load(file).apply(new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter()).into(this.mAutoIcon);
                this.mIdDelIcon.setVisibility(View.VISIBLE);
                return;
            }
            Glide.with((FragmentActivity) this).load(valueOf).into(this.mAutoIcon);
            this.mIdDelIcon.setVisibility(View.GONE);
            return;
        }
        Glide.with((FragmentActivity) this).load(valueOf).into(this.mAutoIcon);
        this.mIdDelIcon.setVisibility(View.GONE);
    }

    private void setRecycleView() {
        this.mRecyclerView.addItemDecoration(new DefaultItemDecoration(getResources().getColor(R.color.gray), -1, 1, 99));
        OnItemMoveListener r0 = new OnItemMoveListener() {
            @Override // com.yanzhenjie.recyclerview.swipe.touch.OnItemMoveListener
            public boolean onItemMove(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2) {
                AddActionActivity.this.mActionAdapter.sortData(viewHolder.getAdapterPosition(), viewHolder2.getAdapterPosition());
                return true;
            }

            @Override // com.yanzhenjie.recyclerview.swipe.touch.OnItemMoveListener
            public void onItemDismiss(RecyclerView.ViewHolder viewHolder) {
                viewHolder.getAdapterPosition();
            }
        };
        this.mRecyclerView.setLongPressDragEnabled(true);
        this.mRecyclerView.setOnItemMoveListener(r0);
        this.mRecyclerView.setOnItemStateChangedListener(new OnItemStateChangedListener() {

            @Override // com.yanzhenjie.recyclerview.swipe.touch.OnItemStateChangedListener
            public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int i) {
                if (i == 0) {
                    viewHolder.itemView.setAlpha(1.0f);
                    viewHolder.itemView.findViewById(R.id.id_main).setBackgroundResource(R.drawable.whitebg_5dp);
                } else if (i == 2) {
                    viewHolder.itemView.setAlpha(0.5f);
                    viewHolder.itemView.findViewById(R.id.id_main).setBackgroundResource(R.drawable.color_bg_red);
                }
            }
        });
    }

    private void showListview() {
        if (AutoUtils.mActionBeanList != null && AutoUtils.mActionBeanList.size() > 0) {
            sortData();
        }
        ActionAdapter actionAdapter = this.mActionAdapter;
        if (actionAdapter == null) {
            this.mRecyclerView.setLayoutManager(new LinearLayoutManager(this, 1, false));
            ActionAdapter actionAdapter2 = new ActionAdapter();
            this.mActionAdapter = actionAdapter2;
            this.mRecyclerView.setAdapter(actionAdapter2);
            View inflate = View.inflate(this, R.layout.item_footview, null);
            inflate.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass4 */

                public void onClick(View view) {
                    if (!CheckUtil.checkOp(AddActionActivity.this)) {
                        ToastUtil.warning("请先打开悬浮窗权限！");
                        ActionNormalSDK.getInstance().gotoFloatPermissionSetting(AddActionActivity.this);
                        return;
                    }
                    ClickUtils.onlyVibrate(AddActionActivity.this);
                    if (FloatUtil.getFirstShow(AddActionActivity.this)) {
                        AddActionActivity addActionActivity = AddActionActivity.this;
                        addActionActivity.mDialog = LayoutDialogUtil.createDailog(addActionActivity, R.layout.dialog_help_text);
                        ((TextView) AddActionActivity.this.mDialog.findViewById(R.id.tv_cancel)).setOnClickListener(new View.OnClickListener() {
                            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass4.AnonymousClass1 */

                            public void onClick(View view) {
                                AddActionActivity.this.mDialog.dismiss();
                            }
                        });
                        ((TextView) AddActionActivity.this.mDialog.findViewById(R.id.tv_sure)).setOnClickListener(new View.OnClickListener() {
                            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass4.AnonymousClass2 */

                            public void onClick(View view) {
                                FloatUtil.setFirstShow(AddActionActivity.this, false);
                                AutoUtils.insertNum = -1;
                                FloatManager.show(InitFloatBean.FloatType.action);
                                AddActionActivity.this.mDialog.dismiss();
                            }
                        });
                        return;
                    }
                    try {
                        AutoUtils.insertNum = -1;
                        ToastUtil.warning(AddActionActivity.this.getString(R.string.drag_tip));
                        FloatManager.show(InitFloatBean.FloatType.action);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            this.mRecyclerView.addFooterView(inflate);
            return;
        }
        actionAdapter.notifyDataSetChanged();
    }

    private void sortData() {
        Collections.sort(AutoUtils.mActionBeanList, new Comparator<ActionBean>() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass5 */

            public int compare(ActionBean actionBean, ActionBean actionBean2) {
                if (actionBean.getSortNum() > actionBean2.getSortNum()) {
                    return 1;
                }
                return actionBean.getSortNum() == actionBean2.getSortNum() ? 0 : -1;
            }
        });
    }

    @Override // com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    private void saveData() {
        try {
            boolean bool;
            AutoUtils.insertNum = -1;
            FloatManager.hide(InitFloatBean.FloatType.action);
            AutoUtils.mAutoName = this.mIdEditName.getText().toString().trim();
            if (TextUtils.isEmpty(AutoUtils.mAutoName)) {
                ToastUtil.warning("addaction activity 警告");
                return;
            }
            AutoUtils.mRepeatTime = MathUtils.parseInt(this.mIdEditTime.getText().toString().trim());
            AutoUtils.mRandomMin = MathUtils.parseInt(this.mIdRandomMin.getText().toString().trim());
            AutoUtils.mRandomMax = MathUtils.parseInt(this.mIdRandomMax.getText().toString().trim());
            if (AutoUtils.mRepeatTime < -1)
                AutoUtils.mRepeatTime = 1;
            if (AutoUtils.mRandomMin <= 0)
                AutoUtils.mRandomMin = 1;
            if (AutoUtils.mRandomMax <= 0)
                AutoUtils.mRandomMax = 1;
            if (AutoUtils.mRepeatTime == 0)
                AutoUtils.mRepeatTime = -1;
            ActionBeanSqlUtil.getInstance().addList(AutoUtils.mAutoID, AutoUtils.mActionBeanList);
            if (AutoUtils.mAutoType.equals(AutoTypeEnum.time.toString()) ? this.mIdSwitch.isChecked() : this.mIdSwitch.isChecked()) {
                bool = true;
            } else {
                bool = false;
            }
            AutoBean autoBean = new AutoBean(null, AutoUtils.mAutoID, AutoUtils.mAutoType, AutoUtils.mAutoName, AutoUtils.mRepeatTime, AutoUtils.mAutoTypeDetail, this.mIdSwitch.isChecked(), TimeUtils.createDay(), AutoUtils.mGroupID, MyApp.mWidth, MyApp.mHeight, "", "", "", "", false, "", false, "", AutoBeanSqlUtil.getInstance().searchAll().size() + 1, this.mIdRandomCheck.isChecked(), AutoUtils.mRandomMin, AutoUtils.mRandomMax, bool);
            AutoBeanSqlUtil.getInstance().add(autoBean);
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("当前随机数=");
                    stringBuilder.append(ADSDK.mIsGDT);
            stringBuilder.append(":");
            stringBuilder.append(ADSDK.nowVersion);
            LogUtil.d("AddActionActivity00", stringBuilder.toString());
            if (ADSDK.mIsGDT || DataUtil.getVip(MyApp.getContext())) {
                out();
                return;
            }
            if (AutoBeanSqlUtil.getInstance().searchAll().size() > 2) {
                int i = RandomUtil.getRandomNum(1, 3);
                stringBuilder = new StringBuilder();
                stringBuilder.append("当前随机数=");
                        stringBuilder.append(i);
                LogUtil.d("AddActionActivity00", stringBuilder.toString());
                if (i == 2) {
                   AddActionActivity.this.out();
                } else {
                    out();
                }
            } else {
                out();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void out() {
        Intent intent = new Intent(this, MainActivity.class);
        this.mIntent = intent;
        intent.putExtra("flag", "auto");
        startActivity(this.mIntent);
        NoticManager.getInstance().updateAutoNotic();
        finish();
    }

    private void choseAutoType() {
        Dialog dialog = this.mDialogChose;
        if (dialog != null) {
            dialog.dismiss();
        }
        Dialog createDailog = LayoutDialogUtil.createDailog(this, R.layout.dialog_chose_auto_type);
        this.mDialogChose = createDailog;
        final RadioGroup radioGroup = (RadioGroup) createDailog.findViewById(R.id.id_bt01_layout);
        final RadioGroup radioGroup2 = (RadioGroup) this.mDialogChose.findViewById(R.id.id_bt02_layout);
        final RadioButton radioButton = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt01);
        final RadioButton radioButton2 = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt01_1);
        final RadioButton radioButton3 = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt01_2);
        final RadioButton radioButton4 = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt02);
        final RadioButton radioButton5 = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt02_1);
        final RadioButton radioButton6 = (RadioButton) this.mDialogChose.findViewById(R.id.id_bt02_2);
        final EditText editText = (EditText) this.mDialogChose.findViewById(R.id.id_edit_text);
        radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass7 */

            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                radioGroup.setVisibility(z ? View.VISIBLE : View.GONE);
            }
        });
        radioButton4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass8 */

            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                radioGroup2.setVisibility(z ? View.VISIBLE : View.GONE);
            }
        });
        this.mDialogChose.setCancelable(false);
        ((TextView) this.mDialogChose.findViewById(R.id.id_cancel)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass9 */

            public void onClick(View view) {
                AddActionActivity.this.mDialogChose.dismiss();
            }
        });
        ((TextView) this.mDialogChose.findViewById(R.id.id_sure)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass10 */

            public void onClick(View view) {
                int i;
                AddActionActivity addActionActivity;
                StringBuilder sb;
                String obj = editText.getText().toString();
                if (TextUtils.isEmpty(obj)) {
                    ToastUtil.warning(AddActionActivity.this.getString(R.string.input_tt));
                    return;
                }
                if (radioButton.isChecked()) {
                    if (!radioButton2.isChecked() && !radioButton3.isChecked()) {
                        ToastUtil.warning(AddActionActivity.this.getString(R.string.chose_one));
                        return;
                    }
                } else if (!radioButton4.isChecked()) {
                    ToastUtil.warning(AddActionActivity.this.getString(R.string.chose_ww));
                    return;
                } else if (!radioButton5.isChecked() && !radioButton6.isChecked()) {
                    ToastUtil.warning(AddActionActivity.this.getString(R.string.chose_one));
                    return;
                }
                if (radioButton2.isChecked()) {
                    AutoUtils.mAutoType = AutoTypeEnum.notic_now.toString();
                }
                if (radioButton3.isChecked()) {
                    AutoUtils.mAutoType = AutoTypeEnum.notic.toString();
                }
                if (radioButton5.isChecked()) {
                    AutoUtils.mAutoType = AutoTypeEnum.screen_now.toString();
                }
                if (radioButton6.isChecked()) {
                    AutoUtils.mAutoType = AutoTypeEnum.screen.toString();
                }
                AutoUtils.mAutoTypeDetail = obj;
                TextView textView = AddActionActivity.this.mIdAutoTypeText;
                if (radioButton.isChecked()) {
                    sb = new StringBuilder();
                    addActionActivity = AddActionActivity.this;
                    i = R.string.tip_k;
                } else {
                    sb = new StringBuilder();
                    addActionActivity = AddActionActivity.this;
                    i = R.string.screen_k;
                }
                sb.append(addActionActivity.getString(i));
                sb.append(obj);
                textView.setText(sb.toString());
                AddActionActivity.this.mDialogChose.dismiss();
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void freshActionData() {
        try {
            if (AutoUtils.mActionBeanList != null && AutoUtils.mActionBeanList.size() > 0) {
                sortData();
            }
            ActionAdapter actionAdapter = this.mActionAdapter;
            if (actionAdapter != null) {
                actionAdapter.notifyDataSetChanged();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override // android.support.v7.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        exit();
        return false;
    }

    public void exit() {
        try {
            if (System.currentTimeMillis() - this.exitTime > 2000) {
                ToastUtil.warning(getString(R.string.c_more));
                this.exitTime = System.currentTimeMillis();
                return;
            }
            AutoUtils.insertNum = -1;
            FloatManager.hide(InitFloatBean.FloatType.action);
            finish();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        this.mIdEditName = (EditText) findViewById(R.id.id_edit_name);
        this.mAutoIcon = (RoundedImageView) findViewById(R.id.auto_icon);
        this.mIdDelIcon = (ImageView) findViewById(R.id.id_del_icon);
        this.mIdGroup = (TextView) findViewById(R.id.id_group);
        this.mIdEditGroup = (ImageView) findViewById(R.id.id_edit_group);
        this.mIdGroupLayout = (LinearLayout) findViewById(R.id.id_group_layout);
        this.mIdSwitchText = (MyTitleView) findViewById(R.id.id_switch_text);
        this.mIdSwitch = (SwitchCompat) findViewById(R.id.id_switch);
        this.mIdSwitchLayout = (LinearLayout) findViewById(R.id.id_switch_layout);
        this.mIdRandomCheck = (CheckBox) findViewById(R.id.id_random_check);
        this.mIdRandomMin = (EditText) findViewById(R.id.id_random_min);
        this.mIdRandomMax = (EditText) findViewById(R.id.id_random_max);
        this.mIdRandomLayout = (LinearLayout) findViewById(R.id.id_random_layout);
        this.mIdEditTime = (EditText) findViewById(R.id.id_edit_time);
        this.mIdAutoTypeText = (TextView) findViewById(R.id.id_auto_type_text);
        this.mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
        this.mIdBt01 = (RadioButton) findViewById(R.id.id_bt01);
        this.mIdBt02 = (RadioButton) findViewById(R.id.id_bt02);
        this.mIdBt03 = (RadioButton) findViewById(R.id.id_bt03);
        this.mIdTopLayout = (LinearLayout) findViewById(R.id.id_top_layout);
        this.mIdShouqi = (ImageView) findViewById(R.id.id_shouqi);
        this.mIdShouqiLayout = (LinearLayout) findViewById(R.id.id_shouqi_layout);
        this.mAutoIcon.setOnClickListener(this);
        this.mIdDelIcon.setOnClickListener(this);
        this.mIdEditGroup.setOnClickListener(this);
        this.mIdSwitch.setOnClickListener(this);
        this.mIdSwitchLayout.setOnClickListener(this);
        this.mIdRandomCheck.setOnClickListener(this);
        this.mIdBt01.setOnClickListener(this);
        this.mIdBt02.setOnClickListener(this);
        this.mIdBt03.setOnClickListener(this);
        this.mIdShouqiLayout.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.auto_icon /*{ENCODED_INT: 2131296312}*/:
                setIcon();
                return;
            case R.id.id_bt01 /*{ENCODED_INT: 2131296491}*/:
                AutoUtils.mAutoType = AutoTypeEnum.click.toString();
                AutoUtils.mAutoTypeDetail = "";
                this.mIdAutoTypeText.setText(AutoUtils.mAutoTypeDetail);
                this.mIdSwitchText.setTitle("通知栏显示");
                return;
            case R.id.id_bt02 /*{ENCODED_INT: 2131296495}*/:
                if (!AutoUtils.mAutoType.equals(AutoTypeEnum.time.toString())) {
                    AutoUtils.mAutoType = AutoTypeEnum.time.toString();
                    AutoUtils.mAutoTypeDetail = "";
                }
                this.mIdSwitchText.setTitle("开启该定时任务");
                this.mIdSwitch.setChecked(true);
                EditDialogUtil.getInstance().showTimeList(this, AutoUtils.mAutoTypeDetail, new EditDialogUtil.OnTimeListListener() {
                    /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass11 */

                    @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnTimeListListener
                    public void result(List<TimerBean> list) {
                        if (list == null) {
                            list = new ArrayList<>();
                        }
                        AutoUtils.mAutoTypeDetail = new ArrayGson().toJson(list);
                        TextView textView = AddActionActivity.this.mIdAutoTypeText;
                        textView.setText(list.size() + "组定时");
                    }
                }, false);
                return;
            case R.id.id_bt03 /*{ENCODED_INT: 2131296499}*/:
                if (AutoUtils.mAutoType.equals(AutoTypeEnum.time.toString()) || AutoUtils.mAutoType.equals(AutoTypeEnum.click.toString())) {
                    AutoUtils.mAutoTypeDetail = "";
                }
                this.mIdSwitchText.setTitle("开启该触发任务");
                this.mIdSwitch.setChecked(true);
                choseAutoType();
                return;
            case R.id.id_del_icon /*{ENCODED_INT: 2131296577}*/:
                try {
                    File file = new File(Environment.getExternalStorageDirectory() + "/XYClick/temp", AutoUtils.mAutoID + ".jpg");
                    if (file.exists()) {
                        file.delete();
                        Glide.with((FragmentActivity) this).load(Integer.valueOf((int) R.drawable.play_auto_blue)).into(this.mAutoIcon);
                        this.mIdDelIcon.setVisibility(View.GONE);
                        return;
                    }
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
            case R.id.id_edit_group /*{ENCODED_INT: 2131296603}*/:
                chosGroudDialog();
                return;
            case R.id.id_random_check /*{ENCODED_INT: 2131296849}*/:
                if (this.mIdRandomCheck.isChecked()) {
                    this.mIdRandomLayout.setVisibility(View.VISIBLE);
                    this.mIdEditTime.setVisibility(View.GONE);
                    return;
                }
                this.mIdRandomLayout.setVisibility(View.GONE);
                this.mIdEditTime.setVisibility(View.VISIBLE);
                return;
            case R.id.id_shouqi_layout /*{ENCODED_INT: 2131296903}*/:
                if (this.mIdTopLayout.getVisibility() == View.VISIBLE) {
                    this.mIdTopLayout.setVisibility(View.GONE);
                    this.mIdShouqi.setRotation(180.0f);
                    return;
                }
                this.mIdTopLayout.setVisibility(View.VISIBLE);
                this.mIdShouqi.setRotation(0.0f);
                return;
            case R.id.id_switch_layout /*{ENCODED_INT: 2131296925}*/:
                if (this.mIdSwitch.isChecked()) {
                    this.mIdSwitch.setChecked(false);
                    return;
                } else {
                    this.mIdSwitch.setChecked(true);
                    return;
                }
            default:
                return;
        }
    }

    public class ActionAdapter extends RecyclerView.Adapter {
        @Override // android.support.v7.widget.RecyclerView.Adapter
        public int getItemViewType(int i) {
            return 0;
        }

        public ActionAdapter() {
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            return new ActionViewHolder(View.inflate(AddActionActivity.this, R.layout.item_action, null));
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
            bingView(viewHolder, i);
        }

        private void bingView(RecyclerView.ViewHolder viewHolder, final int i) {
            final ActionViewHolder actionViewHolder = (ActionViewHolder) viewHolder;
            final ActionBean actionBean = AutoUtils.mActionBeanList.get(i);
            boolean enable = actionBean.getEnable();
            actionViewHolder.onBg.setVisibility(enable ? View.VISIBLE : View.GONE);
            actionViewHolder.offBg.setVisibility(enable ? View.GONE : View.VISIBLE);
            if (FloatUtil.getAutoMs(AddActionActivity.this)) {
                TextView textView = actionViewHolder.time;
                textView.setText(actionBean.getDelay() + AddActionActivity.this.getString(R.string.ms_));
            } else {
                TextView textView2 = actionViewHolder.time;
                textView2.setText(actionBean.getDelay() + AddActionActivity.this.getString(R.string.s_));
            }
            actionViewHolder.actionDetail.setText(actionBean.getActionName());
            TextView textView3 = actionViewHolder.name;
            textView3.setText((i + 1) + ":" + actionBean.getActionName());
            String mark = actionBean.getMark();
            if (TextUtils.isEmpty(mark)) {
                actionViewHolder.actionDetail.setText(AutoUtils.getMarkString(actionBean));
            } else {
                actionViewHolder.actionDetail.setText(mark);
            }
            String actionType = actionBean.getActionType();
            DetailBean detailBean = (DetailBean) new ArrayGson().fromJson(actionBean.getDetail(), DetailBean.class);
            Constants.ActionEnum findEnum = AddActionActivity.this.findEnum(actionType);
            if (findEnum != null) {
                actionType.hashCode();
                char c = 65535;
                switch (actionType.hashCode()) {
                    case -1131150297:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_IMG_DELAY)) {
                            c = 0;
                            break;
                        }
                        break;
                    case -833024575:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_DRAP_CLICK_IMG)) {
                            c = 1;
                            break;
                        }
                        break;
                    case -815136703:
                        if (actionType.equals(Constants.ACTION_TYPE_OPEN_APP_NEW)) {
                            c = 2;
                            break;
                        }
                        break;
                    case 4088742:
                        if (actionType.equals(Constants.ACTION_TYPE_CLICK_IMG_OFFSET)) {
                            c = 3;
                            break;
                        }
                        break;
                    case 466857327:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_CLICK_IMG_TIMES_RECT)) {
                            c = 4;
                            break;
                        }
                        break;
                    case 484400777:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_LONG_CLICK_IMG)) {
                            c = 5;
                            break;
                        }
                        break;
                    case 500571023:
                        if (actionType.equals(Constants.ACTION_TYPE_DO_INSIGN_AUTO)) {
                            c = 6;
                            break;
                        }
                        break;
                    case 961237000:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_CLICK_IMG_ALL)) {
                            c = 7;
                            break;
                        }
                        break;
                    case 1210798333:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_IMG_PICK)) {
                            c = '\b';
                            break;
                        }
                        break;
                    case 1563175462:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_CLICK_IMG)) {
                            c = '\t';
                            break;
                        }
                        break;
                    case 2144954836:
                        if (actionType.equals(Constants.ACTION_TYPE_RES_CLICK_IMG_TIMES)) {
                            c = '\n';
                            break;
                        }
                        break;
                }
                switch (c) {
                    case 0:
                    case 1:
                    case 3:
                    case 4:
                    case 5:
                    case 7:
                    case '\b':
                    case '\t':
                    case '\n':
                        actionViewHolder.img.setVisibility(View.GONE);
                        actionViewHolder.imgShort.setVisibility(View.VISIBLE);
                        Glide.with((FragmentActivity) AddActionActivity.this).load(detailBean.getImgPath()).apply(new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter()).into(actionViewHolder.imgShort);
                        break;
                    case 2:
                        actionViewHolder.img.setVisibility(View.GONE);
                        actionViewHolder.imgShort.setVisibility(View.VISIBLE);
                        try {
                            actionViewHolder.imgShort.setImageDrawable(AddActionActivity.this.getPackageManager().getApplicationIcon(detailBean.getPackName()));
                            break;
                        } catch (Exception e) {
                            e.printStackTrace();
                            break;
                        }
                    case 6:
                        actionViewHolder.img.setVisibility(View.VISIBLE);
                        actionViewHolder.imgShort.setVisibility(View.GONE);
                        Glide.with((FragmentActivity) AddActionActivity.this).load(Integer.valueOf((int) R.drawable.play_auto)).into(actionViewHolder.img);
                        break;
                    default:
                        actionViewHolder.img.setVisibility(View.VISIBLE);
                        actionViewHolder.imgShort.setVisibility(View.GONE);
                        Glide.with((FragmentActivity) AddActionActivity.this).load(Integer.valueOf(findEnum.getImg())).into(actionViewHolder.img);
                        break;
                }
            } else {
                actionViewHolder.img.setVisibility(View.VISIBLE);
                actionViewHolder.imgShort.setVisibility(View.GONE);
            }
            actionViewHolder.more.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass1 */

                public void onClick(View view) {
                    AddActionActivity.this.showMoreDialog(i);
                }
            });
            actionViewHolder.sort.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass2 */

                public void onClick(View view) {
                    ToastUtil.warning(AddActionActivity.this.getString(R.string.l_p_d));
                }
            });
            actionViewHolder.timeLayout.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    AddActionActivity addActionActivity;
                    int i;
                    EditDialogUtil instance = EditDialogUtil.getInstance();
                    AddActionActivity addActionActivity2 = AddActionActivity.this;
                    String string = AddActionActivity.this.getString(R.string.delay_time);
                    if (FloatUtil.getAutoMs(AddActionActivity.this)) {
                        addActionActivity = AddActionActivity.this;
                        i = R.string.input_t1;
                    } else {
                        addActionActivity = AddActionActivity.this;
                        i = R.string.input_t;
                    }
                    instance.edit(addActionActivity2, 2, string, addActionActivity.getString(i), "", new EditDialogUtil.EditMethod() {
                        /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass3.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.Util.EditDialogUtil.EditMethod
                        public void edit(String str) {
                            try {
                                actionBean.setDelay(MathUtils.parseInt(str));
                                if (FloatUtil.getAutoMs(AddActionActivity.this)) {
                                    TextView textView = actionViewHolder.time;
                                    textView.setText(actionBean.getDelay() + AddActionActivity.this.getString(R.string.mh0));
                                    return;
                                }
                                TextView textView2 = actionViewHolder.time;
                                textView2.setText(actionBean.getDelay() + AddActionActivity.this.getString(R.string.sh0));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }, false);
                }
            });
            actionViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass4 */

                public void onClick(View view) {
                    EditDialogUtil.getInstance().edit(AddActionActivity.this, 1, AddActionActivity.this.getString(R.string.note), AddActionActivity.this.getString(R.string.i_order), actionBean.getMark(), new EditDialogUtil.EditMethod() {
                        /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass4.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.Util.EditDialogUtil.EditMethod
                        public void edit(String str) {
                            actionBean.setMark(str);
                            actionViewHolder.actionDetail.setText(str);
                        }
                    }, false);
                }
            });
            actionViewHolder.edit.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass5 */

                public void onClick(View view) {
                    EditDialogUtil.getInstance().detail(AddActionActivity.this, actionBean, new EditDialogUtil.OnDetailListener() {
                        /* class com.lmiot.xyclick.Activity.AddActionActivity.ActionAdapter.AnonymousClass5.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnDetailListener
                        public void result(ActionBean actionBean) {
                            AutoUtils.mActionBeanList.set(i, actionBean);
                            if (AddActionActivity.this.mActionAdapter != null) {
                                AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            }
                            AddActionActivity.this.freshActionData();
                        }
                    });
                }
            });
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public int getItemCount() {
            if (AutoUtils.mActionBeanList == null) {
                return 0;
            }
            return AutoUtils.mActionBeanList.size();
        }

        public void sortData(int i, int i2) {
            try {
                Collections.swap(AutoUtils.mActionBeanList, i, i2);
                notifyItemMoved(i, i2);
                for (int i3 = 0; i3 < AutoUtils.mActionBeanList.size(); i3++) {
                    AutoUtils.mActionBeanList.get(i3).setSortNum(i3);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        /* access modifiers changed from: private */
        public class ActionViewHolder extends RecyclerView.ViewHolder {
            TextView actionDetail;
            LinearLayout detailLayout;
            ImageView edit;
            ImageView img;
            ImageView imgShort;
            ImageView more;
            TextView name;
            ImageView offBg;
            ImageView onBg;
            ImageView sort;
            TextView time;
            LinearLayout timeLayout;

            public ActionViewHolder(View view) {
                super(view);
                this.onBg = (ImageView) view.findViewById(R.id.cb_bg);
                this.offBg = (ImageView) view.findViewById(R.id.cb_bg_gray);
                this.img = (ImageView) view.findViewById(R.id.id_img);
                this.imgShort = (ImageView) view.findViewById(R.id.id_img_short);
                this.more = (ImageView) view.findViewById(R.id.id_more);
                this.sort = (ImageView) view.findViewById(R.id.id_sort);
                this.name = (TextView) view.findViewById(R.id.id_name);
                this.actionDetail = (TextView) view.findViewById(R.id.id_detail_text);
                this.detailLayout = (LinearLayout) view.findViewById(R.id.id_detail_layout);
                this.timeLayout = (LinearLayout) view.findViewById(R.id.id_time_layout);
                this.time = (TextView) view.findViewById(R.id.id_time);
                this.edit = (ImageView) view.findViewById(R.id.id_edit);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private Constants.ActionEnum findEnum(String str) {
        Constants.ActionEnum[] values = Constants.ActionEnum.values();
        for (Constants.ActionEnum actionEnum : values) {
            if (actionEnum.getType().equals(str)) {
                return actionEnum;
            }
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showMoreDialog(final int i) {
        try {
            final ActionBean actionBean = AutoUtils.mActionBeanList.get(i);
            ArrayList arrayList = new ArrayList();
            final boolean enable = actionBean.getEnable();
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.edit_time, "修改属性", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.insert, "插入动作", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.no_use, enable ? "屏蔽动作" : "取消屏蔽", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.del, "删除该动作", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.copy, "复制动作到最后", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.no_use_up, "屏蔽前面所有动作", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.no_use_down, "屏蔽后面所有动作", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.no_use_done, "取消屏蔽所有动作", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.copy, "复制动作到剪切板", null));
            arrayList.add(new EditDialogUtil.MenuBean(R.drawable.past, "粘贴动作到此处", null));
            EditDialogUtil.getInstance().buttomMenuDialog(this, 8, arrayList, new EditDialogUtil.OnMenuClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass12 */

                @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnMenuClickListener
                public void click(int i) {
                    switch (i) {
                        case 0:
                            EditDialogUtil.getInstance().detail(AddActionActivity.this, actionBean, new EditDialogUtil.OnDetailListener() {
                                /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass12.AnonymousClass1 */

                                @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnDetailListener
                                public void result(ActionBean actionBean) {
                                    try {
                                        AutoUtils.mActionBeanList.set(i, actionBean);
                                        if (AddActionActivity.this.mActionAdapter != null) {
                                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                                        }
                                        AddActionActivity.this.freshActionData();
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            return;
                        case 1:
                            AutoUtils.insertNum = i;
                            ToastUtil.warning(AddActionActivity.this.getString(R.string.d_t_o));
                            FloatManager.show(InitFloatBean.FloatType.action);
                            return;
                        case 2:
                            actionBean.setEnable(true ^ enable);
                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            return;
                        case 3:
                            AutoUtils.mActionBeanList.remove(i);
                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            return;
                        case 4:
                            int size = AutoUtils.mActionBeanList.size();
                            List<ActionBean> list = AutoUtils.mActionBeanList;
                            list.add(new ActionBean(null, actionBean.getActionID() + "_" + size, actionBean.getActionName(), actionBean.getActionType(), actionBean.getDelay(), size, actionBean.getDetail(), actionBean.getCreateTime(), actionBean.getAutoID(), actionBean.getUseTime(), actionBean.getIcon(), actionBean.getColor(), actionBean.getEnable(), actionBean.getUnit(), actionBean.getUuid(), actionBean.getMark()));
                            AddActionActivity.this.sortData();
                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            return;
                        case 5:
                            for (int i2 = 0; i2 < AutoUtils.mActionBeanList.size(); i2++) {
                                if (i2 < i) {
                                    AutoUtils.mActionBeanList.get(i2).setEnable(false);
                                }
                            }
                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            return;
                        case 6:
                            for (int i3 = 0; i3 < AutoUtils.mActionBeanList.size(); i3++) {
                                if (i3 > i) {
                                    AutoUtils.mActionBeanList.get(i3).setEnable(false);
                                }
                            }
                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                            return;
                        case 7:
                            break;
                        case 8:
                            if (DataUtil.mCopyActionJsonList == null) {
                                DataUtil.mCopyActionJsonList = new ArrayList();
                            }
                            DataUtil.mCopyActionJsonList.add(new Gson().toJson(actionBean));
                            ToastUtil.success("动作复制成功");
                            return;
                        case 9:
                            if (DataUtil.mCopyActionJsonList == null) {
                                DataUtil.mCopyActionJsonList = new ArrayList();
                            }
                            if (DataUtil.mCopyActionJsonList.size() == 0) {
                                ToastUtil.warning("请先复制一个动作到剪切板");
                                return;
                            } else {
                                EditDialogUtil.getInstance().buttomCopyListDialog(MyApp.getContext(), new EditDialogUtil.OnCopyClickListener() {
                                    /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass12.AnonymousClass2 */

                                    @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnCopyClickListener
                                    public void click(ActionBean actionBean) {
                                        if (actionBean != null) {
                                            actionBean.setId(null);
                                            actionBean.setAutoID(AutoUtils.mAutoID);
                                            actionBean.setActionID(TimeUtils.createID());
                                            actionBean.setSortNum(i + 1);
                                            AutoUtils.mActionBeanList.add(i + 1, actionBean);
                                            AddActionActivity.this.sortData();
                                            AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                                            ToastUtil.success("动作粘贴成功！");
                                        }
                                    }
                                });
                                return;
                            }
                        default:
                            return;
                    }
                    for (int i4 = 0; i4 < AutoUtils.mActionBeanList.size(); i4++) {
                        AutoUtils.mActionBeanList.get(i4).setEnable(true);
                    }
                    AddActionActivity.this.mActionAdapter.notifyDataSetChanged();
                }
            }, false, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void chosGroudDialog() {
        Dialog dialog = this.mDialog;
        if (dialog != null && dialog.isShowing()) {
            this.mDialog.dismiss();
        }
        Dialog createDailog = LayoutDialogUtil.createDailog(this, R.layout.dialog_chose_group);
        this.mDialog = createDailog;
        ListView listView = (ListView) createDailog.findViewById(R.id.id_listivew);
        List<GroupBean> searchAll = GroupBeanSqlUtil.getInstance().searchAll();
        if (searchAll.size() > 5) {
            listView.setLayoutParams(new LinearLayout.LayoutParams(-1, DpUtil.dip2px(this, 300.0f)));
        } else {
            listView.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
        }
        listView.setAdapter((ListAdapter) new GroupAdapter(searchAll));
        ((TextView) this.mDialog.findViewById(R.id.tv_sure)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass13 */

            public void onClick(View view) {
                GroupBean searchByID = GroupBeanSqlUtil.getInstance().searchByID(AutoUtils.mGroupID);
                if (searchByID != null) {
                    AddActionActivity.this.mIdGroup.setText(searchByID.getGroupName());
                }
                AddActionActivity.this.mDialog.dismiss();
            }
        });
        ((TextView) this.mDialog.findViewById(R.id.tv_cancel)).setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                AddActionActivity.this.mDialog.dismiss();
            }
        });
    }

    /* access modifiers changed from: private */
    public class GroupAdapter extends BaseAdapter {
        List<GroupBean> list;

        public Object getItem(int i) {
            return null;
        }

        public long getItemId(int i) {
            return 0;
        }

        public GroupAdapter(List<GroupBean> list2) {
            this.list = list2;
        }

        public int getCount() {
            return this.list.size();
        }

        public View getView(final int i, View view, ViewGroup viewGroup) {
            View inflate = View.inflate(AddActionActivity.this, R.layout.item_chose_group, null);
            ImageView imageView = (ImageView) inflate.findViewById(R.id.id_checked);
            ImageView imageView2 = (ImageView) inflate.findViewById(R.id.id_unchecked);
            ((TextView) inflate.findViewById(R.id.id_name)).setText(this.list.get(i).getGroupName());
            if (AutoUtils.mGroupID.equals(this.list.get(i).getGroupID())) {
                imageView.setVisibility(View.VISIBLE);
                imageView2.setVisibility(View.GONE);
            } else {
                imageView.setVisibility(View.GONE);
                imageView2.setVisibility(View.VISIBLE);
            }
            inflate.setOnClickListener(new View.OnClickListener() {
                /* class com.lmiot.xyclick.Activity.AddActionActivity.GroupAdapter.AnonymousClass1 */

                public void onClick(View view) {
                    AutoUtils.mGroupID = GroupAdapter.this.list.get(i).getGroupID();
                    GroupAdapter.this.notifyDataSetChanged();
                }
            });
            return inflate;
        }
    }

    private void setIcon() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new EditDialogUtil.MenuBean(R.drawable.chose_pic, "选择相册", null));
        arrayList.add(new EditDialogUtil.MenuBean(R.drawable.chose_camera, "前往拍照", null));
        arrayList.add(new EditDialogUtil.MenuBean(R.drawable.reset, "恢复默认", null));
        EditDialogUtil.getInstance().buttomMenuDialog(this, 4, arrayList, new EditDialogUtil.OnMenuClickListener() {
            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15 */

            @Override // com.lmiot.xyclick.Util.EditDialogUtil.OnMenuClickListener
            public void click(int i) {
                if (i == 0) {
                    YYPerUtils.sd(AddActionActivity.this, "读取本地图片需要申请存储权限哦", new OnPerListener() {
                        /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass1 */

                        @Override // com.youyi.yypermissionlibrary.SDK.OnPerListener
                        public void result(boolean z, String str) {
                            if (z) {
                                YYChoseSDK.getInstance(AddActionActivity.this).chosePic(false, 1, new YYChoseSDK.OnSelectListener() {
                                    /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass1.AnonymousClass1 */

                                    @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                                    public void onCancel() {
                                    }

                                    @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                                    public void onResult(ArrayList<Photo> arrayList, boolean z) {
                                        YYCutSDK.getInstance(AddActionActivity.this).cut(arrayList.get(0).path, true, YYCutSDK.CutShape.Oval, new YYCutSDK.OnYYCutListener() {
                                            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass1.AnonymousClass1.AnonymousClass1 */

                                            @Override // com.youyi.yycutsdklibrary.SDK.YYCutSDK.OnYYCutListener
                                            public void result(boolean z, String str, Bitmap bitmap) {
                                                if (z) {
                                                    ImgUtil.saveBitmpToFile(bitmap, new File(Environment.getExternalStorageDirectory() + "/XYClick/temp", AutoUtils.mAutoID + ".jpg"));
                                                    AddActionActivity.this.showAutoIcon();
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    });
                } else if (i == 1) {
                    YYPerUtils.camera(AddActionActivity.this, "拍照需要申请相机权限哦", new OnPerListener() {
                        /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass2 */

                        @Override // com.youyi.yypermissionlibrary.SDK.OnPerListener
                        public void result(boolean z, String str) {
                            if (z) {
                                YYChoseSDK.getInstance(AddActionActivity.this).camera(new YYChoseSDK.OnSelectListener() {
                                    /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass2.AnonymousClass1 */

                                    @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                                    public void onCancel() {
                                    }

                                    @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                                    public void onResult(ArrayList<Photo> arrayList, boolean z) {
                                        YYCutSDK.getInstance(AddActionActivity.this).cut(arrayList.get(0).path, true, YYCutSDK.CutShape.Oval, new YYCutSDK.OnYYCutListener() {
                                            /* class com.lmiot.xyclick.Activity.AddActionActivity.AnonymousClass15.AnonymousClass2.AnonymousClass1.AnonymousClass1 */

                                            @Override // com.youyi.yycutsdklibrary.SDK.YYCutSDK.OnYYCutListener
                                            public void result(boolean z, String str, Bitmap bitmap) {
                                                if (z) {
                                                    ImgUtil.saveBitmpToFile(bitmap, new File(Environment.getExternalStorageDirectory() + "/XYClick/temp", AutoUtils.mAutoID + ".jpg"));
                                                    AddActionActivity.this.showAutoIcon();
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    });
                } else if (i == 2) {
                    File file = new File(Environment.getExternalStorageDirectory() + "/XYClick/temp", AutoUtils.mAutoID + ".jpg");
                    if (file.exists()) {
                        file.delete();
                        AddActionActivity.this.showAutoIcon();
                    }
                }
            }
        }, false, false);
    }
}
